﻿/*
 * HCC Robotica, Workshop Robot programmeren met C# 
 * Oefening : wo_01	LED knipperen, methode: aparte thread met sleep
 * Naam     : Hinnie
 * Versie   : september 2011
 */

using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;

namespace wo_01
{
    public class wo_01
    {
        public static void flashLed()               // Blink board LED
        {
            bool ledState = false;
            OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
            while (true)
            {
                Thread.Sleep(200);                  // Sleep for 200 milliseconds
                ledState = !ledState;               // toggle LED state
                led.Write(ledState);
            }
        }

        public static void Main()
        {
            Thread MyThreadHandler;                 // create a thread handler
            MyThreadHandler = new Thread(flashLed); // create a new thread object and assign to my handler
            MyThreadHandler.Start();                // start my new thread
            int Counter = 0;
            while (true)
            {
                Counter++;
                Debug.Print("Amazing " + Counter.ToString());
                Thread.Sleep(1000);                 //sleep this thread for 1 second
            }
        }
    }
}
